package com.learn.controllers;

import com.learn.form.AdminForm;
import com.learn.framework.annotation.FormValidateResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.Map;

@Controller
public class IndexController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    public IndexController(){

    }

    @RequestMapping(value = {"/index","/"}, method = RequestMethod.GET)
    public String IndexAction(Map<String,Object> map){
//        String path2 = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
//        System.out.println("path2 = " + path2);
//        System.out.println(System.getProperty("catalina.home"));
//        System.out.println(model.asMap());
//        model.addAttribute("name", "Dear");
        //日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL，如果设置为WARN，则低于WARN的信息都不会输出。
//        logger.trace("日志输出 trace");
//        logger.debug("日志输出 debug");
//        logger.info("日志输出 info");
//        logger.warn("日志输出 warn");
//        logger.error("日志输出 error");

        return "index";
    }

    @RequestMapping(value = {"/test"})
    public @ResponseBody String testLayout(Model model){
        return "test";
    }
}
